home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #ifdef STAPUFT
-
- #include <gl.h>
-
- extern unsigned long * readImageRGB(char *, int *, int *);
-
- static float texture_def0[] = { TX_NULL };
- static float texture_def1[] = { TX_MINFILTER, TX_MIPMAP_POINT,
- TX_MAGFILTER, TX_POINT,
- TX_NULL };
- static float texture_def2[] = { TX_MINFILTER, TX_MIPMAP_BILINEAR,
- TX_MAGFILTER, TX_BILINEAR,
- TX_NULL };
- static float texture_def3[] = { TX_MINFILTER, TX_BILINEAR,
- TX_MAGFILTER, TX_BILINEAR,
- TX_NULL };
- static float texture_def4[] = { TX_MINFILTER, TX_MIPMAP_LINEAR,
- TX_MAGFILTER, TX_BILINEAR,
- TX_NULL };
-
- bind_texture(name, n, type)
- char *name;
- int n;
- int type;
- {
- static float texture_env[] = { TV_MODULATE, TV_NULL };
- static int init = 1;
-
- int width, height;
- unsigned long *image;
-
- int i;
-
- image = readImageRGB(name,&width,&height);
-
- switch(type) {
- case 0:
- texdef2d(n, 4, width, height, image, 0, texture_def0 );
- break;
- case 1:
- texdef2d(n, 4, width, height, image, 0, texture_def1 );
- break;
- case 2:
- texdef2d(n, 4, width, height, image, 0, texture_def2 );
- break;
- case 3:
- texdef2d(n, 4, width, height, image, 0, texture_def3 );
- break;
- case 4:
- texdef2d(n, 4, width, height, image, 0, texture_def4 );
- break;
- }
-
- if (init) {
- init = 0;
-
- tevdef(1, 0, texture_env);
- /* tevdef(0, 1, 0); */
-
- tevbind(TV_ENV0, 1);
- }
- }
-
- static int backixsize, backiysize;
- static unsigned long *backimgdat;
-
- static float identity[4][4] = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
-
-
- drawback(name)
- char *name;
- {
- static unsigned long * backimgdat;
- static float coord[4][2] = {{0,0},{0,1},{1,1},{1,0}};
-
- if(!backimgdat) {
- int width, height;
-
- backimgdat = readImageRGB(name,&width,&height);
- texdef2d(10, 4, width, height, backimgdat, 0, texture_def0 );
- }
- ortho2(0.0,1.0,0.0,1.0);
- pushmatrix();
- loadmatrix(identity);
-
- texbind(TX_TEXTURE_0, 10);
-
- cpack(-1);
- bgnpolygon();
- t2f(coord[0]);
- v2f(coord[0]);
- t2f(coord[1]);
- v2f(coord[1]);
- t2f(coord[2]);
- v2f(coord[2]);
- t2f(coord[3]);
- v2f(coord[3]);
- endpolygon();
-
- texbind(TX_TEXTURE_0, 0);
-
- popmatrix();
- }
-
- #endif STAPUFT
-